<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="UTF-8">
		<title>红酒会 - 智能红酒管家</title>
		<link rel="shortcut icon" type="image/x-icon" href="${ctx}/favicon.ico" />
		<link type="text/css" rel="stylesheet" href="${ctx}/static/styles/bootstrap.min.css">
	</head>
<body>
	<c:import url="/header"><c:param name="module">vintry</c:param></c:import>
	<c:import url="/vintry/menu"><c:param name="menu">1</c:param></c:import>
	<c:import url="/talk/right" />
	
	<!--outWrap-->
	<div class="outWrap">
		<div class="spekBoxIn">
			
			<div class="alert alert-error">
				<button type="button" class="close" data-dismiss="alert">&times;</button>
 					<strong>提示信息：</strong>
 					该红酒信息已存在，您可以选择使用该信息<br/>
 					如果您认为该红酒信息存在问题，您可以
 					<a href="${ctx}/vintry/wine/advice/${vintry.wine.id}">点击</a>
					纠错
			</div>
			
	<%-- 红酒信息 --%>
	<table class="table">
		<tbody>
			<tr>
				<td colspan="2" rowspan="10" style="text-align:center; vertical-align:middle;">
					<c:choose>
						<c:when test="${not empty vintry.wine.picUrl}">
							<img src="${vintry.wine.picUrl}" width="150px" height="150px" />
						</c:when>
						<c:otherwise>
							<img src="${ctx}/static/images/no_pic.jpg" width="150px" height="150px" />
						</c:otherwise>
					</c:choose>
				<td>中文名称：</td>
				<td>${vintry.wine.chName}</td>
			</tr>
			<tr>
				<td>英文名称：</td>
				<td>${vintry.wine.enName}</td>
			</tr>
			<tr>
				<td>条形码：</td>
				<td>${vintry.wine.barcode}</td>
			</tr>
			<tr>
				<td>分类：</td>
				<td>${vintry.wine.type.name}</td>
			</tr>
			<tr>
				<td>国家：</td>
				<td>${vintry.wine.country.name}</td>
			</tr>
			<tr>
				<td>产地：</td>
				<td>${vintry.wine.region}</td>
			</tr>
			<tr>
				<td>年份：</td>
				<td>${vintry.wine.vintage}</td>
			</tr>
			<tr>
				<td>葡萄总类：</td>
				<td>${vintry.wine.variety}</td>
			</tr>
			<tr>
				<td>容量：</td>
				<td>${vintry.wine.capacity}</td>
			</tr>
			<tr>
				<td>等级：</td>
				<td>${vintry.wine.grade}</td>
			</tr>
		</tbody>
	</table>
	<hr/><br/>
	<form id="form" action="${ctx}/vintry/create" enctype="multipart/form-data" method="post" class="form-horizontal">
		<input type="hidden" name="wine.id" value="${vintry.wine.id}" />
		<input type="file" name="pic" style="display:none" />
		<div class="control-group">
			<label class="control-label" for="price">购买价格</label>
			<div class="controls">
				<div class="input-append">
		 				<input type="text" id="price" name="price" class="input-mini"
		 					value="<fmt:formatNumber value="${vintry.price}" pattern="#0.##"/>" />
		 				<span class="add-on">元</span>
				</div>
				<span id="error_price" class="red"></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="marketPrice">市场价格</label>
			<div class="controls">
				<div class="input-append">
		 				<input type="text" id="marketPrice" name="marketPrice" class="input-mini"
		 					value="<fmt:formatNumber value="${vintry.marketPrice}" pattern="#0.##"/>" />
		 				<span class="add-on">元</span>
				</div>
				<span id="error_marketPrice" class="red"></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="drinkingRange">适饮期</label>
			<div class="controls">
				<div class="input-append">
		    		<input type="text" id="drinkingRange" name="drinkingRange" class="input-mini"
		    			value="${vintry.drinkingRange}"/>
		    		<span class="add-on">年</span>
				</div>
				<span id="error_drinkingRange" class="red"></span>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label" for="remark">备注：</label>
			<div class="controls">
				<textarea id="remark" name="remark" rows="3" class="input-xlarge">${vintry.remark}</textarea>
				<div id="error_remark" class="red"></div>
			</div>
		</div>
		
		<div class="control-group">
		   	<div class="controls">
	   			<button type="button" class="btn" onclick="history.back();">&nbsp;&nbsp;&nbsp;返&nbsp;&nbsp;&nbsp;回&nbsp;&nbsp;&nbsp;</button>
	     		<button type="submit" class="btn btn-info">&nbsp;&nbsp;&nbsp;提&nbsp;&nbsp;&nbsp;交&nbsp;&nbsp;&nbsp;</button>
		   	</div>
		</div>
	</form>

		</div>
	</div>
	
	<c:import url="/WEB-INF/views/footer.jsp" />
	
	<script type="text/javascript" src="${ctx}/static/scripts/bootstrap.min.js"></script>
	<script type="text/javascript" src="${ctx}/static/scripts/jquery.validate.min.js"></script>
	<script type="text/javascript">
		$(function() {
			$('#form').validate({
				rules: {
					price: {
						number: true,
						max: 10000000
					},
					marketPrice: {
						number: true,
						max: 10000000
					},
					drinkingRange: {
						required: true,
						digits: true,
						max: 1000
					},
					remark: {
						maxlength: 100
					}
				},
				messages: {
					price: {
						number: '购买价格只能填写数字',
						max: '购买价格不能超过{0}元'
					},
					marketPrice: {
						number: '市场价格只能填写数字',
						max: '市场价格不能超过{0}元'
					},
					drinkingRange: {
						required: '请填写适饮期',
						digits: '适饮期只能填写整数',
						max: '适饮期不能超过{0}年'
					},
					remark: {
						maxlength: '备注不能超过100个字符'
					}
				},
				errorElement: 'em',
				errorPlacement: function(error, element) {
					error.appendTo($("#error_" + element.attr("id")));
				},
				submitHandler: function(form) {
					form.submit();
				}
			});
		});
	</script>
</body>
</html>